<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>demo</title>
  <script type="text/javascript" src="../vue.js"></script>
  <style>
    .one {
      width: 200px;
      height: 200px;
      background-color: aqua;
    }

    .two {
      width: 100px;
      height: 100px;
      background-color: red;
    }

    .three {
      width: 50px;
      height: 50px;
      background-color: azure;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- capture 使用捕获事件 -->
    <div @click.capture="fn1" class="one">
      <!-- prevent 阻止默认事件 -->
      <!-- stop阻止传播 只有点击添加事件的才会触发 -->
      <div @click.stop="fn2" class="two"></div>
      <!-- once 只会触发一次 -->
      <div @click.once="fn3">{{count}}</div>
      <!-- self 类似event.target 是当前元素自身时触发处理函数 -->
      <div @click.self="fn2" class="three">so?</div>
    </div>
    <!-- 按键修饰符 在监听键盘事件时，我们经常需要检查详细的按键。Vue 允许为 v-on 在监听键盘事件时添加按键修饰符
    -->
    <!-- <input type="text" @keyup.enter="fn1"> -->
    <!-- <input type="text" @keyup.13="fn1"> -->
    <!--按下抬起事件 -->
    <input type="text" @keyup.delete="fn1">
    <!-- tab最好搭配keydown使用才有效果 按下事件 -->
    <input type="text" @keydown.tab="fn2">
  </div>
</body>
<script type="text/javascript">
  Vue.config.productionTip = false
  const vm = new Vue({
    el: "#app",
    data() {
      return {
        count: 22
      }
    },
    methods: {
      fn1() {
        console.log(111);
      },
      fn2() {
        console.log(222);
      },
      fn3() {
        this.count++
      }
    }
  })
</script>

</html>